/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bs.converters;

import java.util.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.beansbinding.Converter;

/**
 *
 * @author Bone
 */
public class ConversorData extends Converter<Date, String> {
private SimpleDateFormat fmt = new SimpleDateFormat("dd/MM/yyyy");

    @Override
    public String convertForward(Date value) {
        if (value == null) {
            return "";
        }
        return fmt.format(new Date(value.getTime()));
    }

    @Override
    public Date convertReverse(String value) {
        try {
            return new Date(fmt.parse(value).getTime());
        } catch (ParseException ex) {
            Logger.getLogger(ConversorData.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
    
}
